﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Workflow.Activities;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
using System.Diagnostics;
using System.Data;
using WFServiceContract;
using WebKpiPage.Data.GongdanMgr;
/// <summary>
/// Summary description for WFGongdan
/// </summary>
namespace WFServiceContract
{
    [Serializable]
    public class WFGongdan : IWFGongdan
    {
        Dictionary<string, EventHandler<ExternalDataEventArgs>> _EventList = new Dictionary<string, EventHandler<ExternalDataEventArgs>>();

        public void RaiseEvent(string name, Guid instanceId)
        {
            if (_EventList[name] != null)
            {
                EventHandler<ExternalDataEventArgs> eventHand = _EventList[name];
                ExternalDataEventArgs ede = new ExternalDataEventArgs(instanceId);
                eventHand(this, ede);
            }
        }
     
        public event EventHandler<ExternalDataEventArgs> EveOK
        {
            add
            {
                _EventList.Add("EveOK", value);
            }
            remove
            {
                _EventList.Remove("EveOK");
            }
        }

        public event EventHandler<ExternalDataEventArgs> EveReject
        {
            add
            {
                _EventList.Add("EveReject", value);
            }
            remove
            {
                _EventList.Remove("EveReject");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveUp
        {
            add
            {
                _EventList.Add("EveUp", value);
            }
            remove
            {
                _EventList.Remove("EveUp");
            }
        }

        public event EventHandler<ExternalDataEventArgs> EveTJ
        {
            add
            {
                _EventList.Add("EveTJ", value);
            }
            remove
            {
                _EventList.Remove("EveTJ");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveTimeOut
        {
            add
            {
                _EventList.Add("EveTimeOut", value);
            }
            remove
            {
                _EventList.Remove("EveTimeOut");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveContinue
        {
            add
            {
                _EventList.Add("EveContinue", value);
            }
            remove
            {
                _EventList.Remove("EveContinue");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveShQysh
        {
            add
            {
                _EventList.Add("EveShQysh", value);
            }
            remove
            {
                _EventList.Remove("EveShQysh");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveWYZGPGOK
        {
            add
            {
                _EventList.Add("EveWYZGPGOK", value);
            }
            remove
            {
                _EventList.Remove("EveWYZGPGOK");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveWYZGTJ
        {
            add
            {
                _EventList.Add("EveWYZGTJ", value);
            }
            remove
            {
                _EventList.Remove("EveWYZGTJ");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveWYZGReject
        {
            add
            {
                _EventList.Add("EveWYZGReject", value);
            }
            remove
            {
                _EventList.Remove("EveWYZGReject");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveTimeOut2
        {
            add
            {
                _EventList.Add("EveTimeOut2", value);
            }
            remove
            {
                _EventList.Remove("EveTimeOut2");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveAgreeSH
        {
            add
            {
                _EventList.Add("EveAgreeSH", value);
            }
            remove
            {
                _EventList.Remove("EveAgreeSH");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveRejectSH
        {
            add
            {
                _EventList.Add("EveRejectSH", value);
            }
            remove
            {
                _EventList.Remove("EveRejectSH");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveWYZRTJ
        {
            add
            {
                _EventList.Add("EveWYZRTJ", value);
            }
            remove
            {
                _EventList.Remove("EveWYZRTJ");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveWYZRReject
        {
            add
            {
                _EventList.Add("EveWYZRReject", value);
            }
            remove
            {
                _EventList.Remove("EveWYZRReject");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveClose
        {
            add
            {
                _EventList.Add("EveClose", value);
            }
            remove
            {
                _EventList.Remove("EveClose");
            }
        }
        public event EventHandler<ExternalDataEventArgs> EveWYZRContinue
        {
            add
            {
                _EventList.Add("EveWYZRContinue", value);
            }
            remove
            {
                _EventList.Remove("EveWYZRContinue");
            }
        } 
        public event EventHandler<ExternalDataEventArgs> EveWYZGContinue
        {
            add
            {
                _EventList.Add("EveWYZGContinue", value);
            }
            remove
            {
                _EventList.Remove("EveWYZGContinue");
            }
        } 
        /// <summary>
        /// 未升级前
        /// </summary>
        /// <param name="InstranceId"></param>
        /// <returns></returns>
        public int ProblemIsDisappear(Guid instranceId)
        {
            int count = GongdanMgrCls.GongdanIsClose(instranceId);
            Trace.WriteLine("Call ProblemIsDisappear " + instranceId.ToString());
            return count;
           
        }
    }
}